package com.jiazhong.Servlet;

import com.jiazhong.Model.Goods;
import com.jiazhong.Service.GoodsService;
import com.jiazhong.Service.Impl.GoodsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/goods/queryGoodsById.do")
public class QueryGoodsByIdServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取goods_id
        int goods_id=Integer.parseInt(request.getParameter("goods_id"));
//        System.out.println(goods_id);
        GoodsService goodsService=new GoodsServiceImpl();
        Goods goods=goodsService.queryGoodsById(goods_id);
        request.setAttribute("goods",goods);
//        System.out.println(goods.getGoods_id()+""+goods.getGoods_name());
        request.getRequestDispatcher("/Goods/updateGoods.jsp").forward(request,response);
    }
}
